home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / windows / comms / mlk104a.arj / HOST.MSL < prev    next >
Text File  |  1992-04-13  |  14KB  |  436 lines

  1. ' Host mode script
  2. ' Access levels are:    3 - Sysop
  3. '                       2 - user can access any directory
  4. '                       1 - user can access only current directory
  5. PUSH
  6. SET ECHO ON
  7. SET TEXTWRAP ON
  8. SET HOSTECHO ON
  9. SET INCRLF ON
  10. SET OUTCRLF ON
  11. SET CARRIERDETECT ON
  12.  
  13. upload_dir$ = uploaddirectory
  14. default_dir$ = defaultdirectory
  15. file_spec$ = filespec
  16.  
  17.  
  18. cr$ = "^M"
  19. cr2$ = "^M^M"
  20. cr3$ = "^M^M^M"
  21. cr4$ = "^M^M^M^M"
  22. cr5$ = "^M^M^M^M^M"
  23. newpage$ = cr5$+cr5$+cr5$+cr5$+cr5$
  24.  
  25. Header$   = "                   Host Mode"
  26.  
  27. welcome1$ = "                 ***********************************"+cr$
  28. welcome2$ = "                 *        Microlink Host Mode      *"+cr$
  29. welcome3$ = "                 *      Press ENTER to Continue    *"+cr$
  30. welcome4$ = "                 ***********************************"+cr5$
  31.  
  32. continue = 1
  33. max_lines = 20
  34.  
  35.  
  36. WHILE continue=1
  37.     if ChangeDirectory(default_dir$) > 0 then
  38.       mprint "Invalid default directory"
  39.       beep
  40.       sleep 5
  41.       continue = 0
  42.       GOTO force_hangup
  43.     endif
  44.  
  45.     current_dir$ = default_dir$
  46.  
  47.     ONERROR force_hangup
  48.     AUTOANSWER
  49.  
  50.  
  51.     ' Computer answered phone
  52.  
  53.     sleep 5
  54.     IF Connected = 0 Then
  55.      goto force_hangup
  56.     endif
  57.     RPRINT newpage$
  58.     RPRINT welcome1$
  59.     RPRINT welcome2$
  60.     RPRINT welcome3$
  61.     RINPUT welcome4$,temp$
  62.     Rprint cr4$
  63.  
  64.     ' Prompts to enter password
  65.     logon_ok = 0
  66.     set error off
  67.     FOR i = 1 TO 3
  68.         onerror skipsignon
  69.         RINPUT cr$+"Enter FIRST name: ", first$
  70.         RINPUT cr$+"Enter LAST name: ", last$
  71.         SET HOSTECHO OFF
  72.         RINPUT cr$+"Enter PASSWORD: ", password$
  73.         set error off
  74.         SET HOSTECHO ON
  75.         logon_ok = VerifyUser(first$, last$, password$)
  76.           IF logon_ok > 1  THEN
  77.             IF OPENHOST = 1 THEN
  78.                 onerror skipnew
  79.                    rprint cr2$+"              N E W   U S E R"+cr2$
  80.                 Rprint cr$+"First Name: "+first$
  81.                    Rprint cr$+"Last Name: "+last$
  82.                    RINPUT cr$+"Correct? ", Temp$
  83.                    logon_ok = 0
  84.                    IF upper(Temp$) = "Y" THEN
  85.                      IF Adduser(first$, last$, password$, 1) > 0 THEN
  86.                            RPRINT cr2$+"Unable To Add User At This Time"
  87.                            logon_ok = 1
  88.                      ENDIF
  89.                      EXIT
  90.                 ENDIF
  91.                 skipnew:
  92.               ELSE
  93.                  RPRINT cr2$+"Invalid logon attempt!"
  94.                   IF i < 3 THEN
  95.                      RPRINT cr$+"There are " + String(3 - i) + " attempts left."
  96.                 ENDIF
  97.               ENDIF
  98.         ELSE
  99.          IF logon_ok = 1  THEN
  100.             RPRINT cr$+"Invalid logon attempt!"
  101.             IF i < 3 THEN
  102.               RPRINT cr$+"There are " + String(3 - i) + " attempts left." + cr$
  103.             ENDIF
  104.          ELSE
  105.            EXIT
  106.          ENDIF
  107.         ENDIF
  108.         skipsignon:
  109.     NEXT
  110.  
  111.     IF logon_ok > 0 THEN
  112.         RPRINT cr2$+"Unable to validate user!"
  113.         RPRINT cr2$+"Hanging up!"
  114.         goto force_hangup
  115.     else
  116.         continue_commands = 1
  117.         access_level = ExtractUserLevel(first$, last$)
  118.         rprint cr4$
  119.     endif
  120.     WHILE continue_commands = 1
  121.         if Connected = 0 then
  122.                EXIT
  123.         endif
  124.         RPRINT cr2$+"         Host Mode Processor"+cr2$
  125.         RPRINT cr$ + "[F]File Directory    [D]Download    [U]Upload"
  126.                  ' Level 2 or 3
  127.         IF access_level > 1  THEN
  128.             RPRINT cr$ + "[CD]Change Directory [FS]File Specification"
  129.         ENDIF
  130.  
  131.         ' Level 3 only
  132.         IF access_level > 2 then
  133.             RPRINT cr$ + "[AU]Add User         [CU]Change User"
  134.             RPRINT cr$ + "[DU]Delete User      [S]ShutDown"
  135.         ENDIF
  136.  
  137.         RPRINT cr$ + "[G]Goodbye"
  138.  
  139.         ' Wait for command
  140.         RINPUT cr2$+current_dir$ + "> ", tempcommand$
  141.         command$ = upper(tempcommand$)
  142.  
  143.         ' Exit System
  144.         if len(command$) = 1 then
  145.             IF command$ = "G"  THEN
  146.                 RPRINT cr$ + "Thanks for calling " + first$ + "!" + cr$
  147.                 continue_commands = 0
  148.                 SLEEP 2
  149.             ENDIF
  150.  
  151.                     ' List Files
  152.             IF command$ = "F" THEN
  153.                 RPRINT cr4$
  154.                 RPRINT "Directory listing of: " + current_dir$ + cr2$
  155.                 ChangeDirectory(current_dir$)
  156.                    filename$ = GetFirstDirEntry(current_dir$, file_spec$)
  157.                 WHILE Len(filename$) > 0
  158.                     IF Connected = 0 Then
  159.                            EXIT
  160.                     endif
  161.                     FOR i = 1 to max_lines
  162.                         RPRINT filename$ + cr$
  163.                         filename$ = GetNextDirEntry()
  164.                         IF Len(filename$) = 0 THEN
  165.                             EXIT
  166.                         ENDIF
  167.                     NEXT
  168.                     IF LEN(filename$) > 0 THEN
  169.                           Rinput cr$+"List paused.  Press ENTER to continue.",temp$
  170.                           IF "C" = upper(temp$) THEN
  171.                                exit
  172.                             ENDIF
  173.                             rprint cr4$
  174.                     ENDIF
  175.                 WEND
  176.  
  177.                 RINPUT cr$+"End of List.   Press ENTER to Continue",temp$
  178.                 rprint cr4$
  179.             ENDIF
  180.  
  181.             ' Download a File
  182.             IF command$ = "D" THEN
  183.                 rprint cr4$
  184.                 WHILE 1 = 1
  185.                     IF Connected = 0 Then
  186.                            EXIT
  187.                     endif
  188.                     RPRINT cr$+Header$+cr3$
  189.                     RPRINT cr$+"Available download file transfer protocols:" + cr2$
  190.                     RPRINT "[X]..XMODEM Checksum" + cr$
  191.                     RPRINT "[C]..XMODEM CRC" + cr$
  192.                     RPRINT "[Y]..YMODEM 1K" + cr$
  193.                     RPRINT "[YB].YMODEM Batch" + cr$
  194.                     RPRINT "[YG].YMODEM G" + cr$
  195.                     RPRINT "[Z]..ZMODEM" + cr$
  196.                     RPRINT "[E]..Cancel" + cr$
  197.                     RINPUT "Select protocol: ", tempchoice$
  198.                     choice$ = upper(tempchoice$)
  199.                     if len(choice$) = 1 then
  200.                           IF choice$ = "E" THEN
  201.                             EXIT
  202.                         ENDIF
  203.                         IF choice$ = "X" THEN
  204.                             set protocol XMODEM
  205.                             EXIT
  206.                         ENDIF
  207.                         IF choice$ = "C" THEN
  208.                             set protocol XMODEMCRC
  209.                             EXIT
  210.                         ENDIF
  211.                         IF choice$ = "Y" THEN
  212.                             set protocol YMODEM
  213.                             EXIT
  214.                         ENDIF
  215.                         IF choice$ = "Z" THEN
  216.                             set protocol ZMODEM
  217.                             EXIT
  218.                         ENDIF
  219.                     endif
  220.                     if len(choice$) = 2 then
  221.                         IF choice$ = "YB" THEN
  222.                             set protocol YMODEMB
  223.                             EXIT
  224.                         ENDIF
  225.                         IF choice$ = "YG" THEN
  226.                             set protocol YMODEMG
  227.                             EXIT
  228.                         ENDIF
  229.                     ENDIF
  230.                     rprint cr2$+"Invalid Selection"+cr2$
  231.                 WEND
  232.                    IF choice$ = "E" THEN
  233.                     rprint "Canceled!"+cr$
  234.                    ELSE
  235.                        ChangeDirectory(current_dir$)
  236.                       RINPUT cr2$+"Enter Filename: ", transfer_file$
  237.                       is_ok = DoesFileExist(transfer_file$)
  238.                       IF is_ok = 1 THEN
  239.                          RPRINT cr$+"File " + transfer_file$ + " was not found." + cr$
  240.                          RPRINT "File transfer canceled!" + cr$
  241.                       ELSE
  242.                          RPRINT cr$+"Downloading " + transfer_file$ + cr$
  243.                          ONERROR snderr
  244.                         SEND transfer_file$
  245.                         sleep 3
  246.                          rprint cr$+"File Transfer Successful"
  247.                          goto sndok
  248.                          snderr:
  249.                               rprint cr2$+"Error Downloading File"
  250.                            rinput cr$+"Hit ENTER to Continue",temp$
  251.                          sndok:
  252.                          set error off
  253.                        ENDIF
  254.                    ENDIF
  255.             ENDIF
  256.         ' Receive a File
  257.             IF command$ = "U" THEN
  258.                 rprint cr4$
  259.                 WHILE 1 = 1
  260.                     IF Connected = 0 Then
  261.                            EXIT
  262.                     endif
  263.                     RPRINT cr$+Header$+cr3$
  264.                     RPRINT "Available Upload file transfer protocols:" + cr2$
  265.                     RPRINT "[X]..XMODEM Checksum" + cr$
  266.                     RPRINT "[C]..XMODEM CRC" + cr$
  267.                     RPRINT "[Y]..YMODEM 1K" + cr$
  268.                     RPRINT "[YB].YMODEM Batch" + cr$
  269.                     RPRINT "[YG].YMODEM G" + cr$
  270.                     RPRINT "[Z]..ZMODEM" + cr$
  271.                     RPRINT "[E]..Exit" + cr$
  272.                     RINPUT "Select protocol: ", tempchoice$
  273.                     choice$ = upper(tempchoice$)
  274.                     if len(choice$) = 1 then
  275.                           IF choice$ = "E" THEN
  276.                             EXIT
  277.                         ENDIF
  278.                         IF choice$ = "X" THEN
  279.                             set protocol XMODEM
  280.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  281.                             is_ok = ValidFileName(transfer_file$)
  282.                             EXIT
  283.                         ENDIF
  284.                         IF choice$ = "C" THEN
  285.                             set protocol XMODEMCRC
  286.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  287.                             is_ok = ValidFileName(transfer_file$)
  288.                             EXIT
  289.                         ENDIF
  290.                         IF choice$ = "Y" THEN
  291.                             set protocol YMODEM
  292.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  293.                             is_ok = ValidFileName(transfer_file$)
  294.                             EXIT
  295.                         ENDIF
  296.                         IF choice$ = "Z" THEN
  297.                             set protocol ZMODEM
  298.                             transfer_file$ = ""
  299.                             is_ok = 1
  300.                             EXIT
  301.                         ENDIF
  302.                     ENDIF
  303.                     if len(choice$) = 2 then
  304.                         IF choice$ = "YB" THEN
  305.                             set protocol YMODEMB
  306.                             transfer_file$ = ""
  307.                             is_ok = 1
  308.                             EXIT
  309.                         ENDIF
  310.                         IF choice$ = "YG" THEN
  311.                             set protocol YMODEMG
  312.                             transfer_file$ = ""
  313.                             is_ok = 1
  314.                             EXIT
  315.                         ENDIF
  316.                     ENDIF
  317.                     rprint cr2$+"Invalid Selection"+cr2$
  318.                 WEND
  319.                   IF choice$ = "E" THEN
  320.                       rprint cr$+"Canceled"+cr$
  321.                   ELSE
  322.                     IF is_ok = 0 THEN
  323.                         RPRINT "File " + transfer_file$ + " was not valid." + cr$
  324.                         RPRINT "File transfer canceled!" + cr$
  325.                     ELSE
  326.  
  327.                         ChangeDirectory(upload_dir$)
  328.                          ONERROR rcverr
  329.                         RPRINT "Uploading " + transfer_file$ +cr$
  330.                         RPRINT cr$+"Start Your File Transfer"+cr$
  331.                         RECEIVE transfer_file$
  332.                         sleep 3
  333.                         RPRINT cr$+"File Transfer Successful"+cr$
  334.                         GOTO rcvok
  335.                         rcverr:
  336.                           Rprint "Error Uploading File - "+transfer_file$+cr$
  337.                           rinput "Hit Enter to Continue",temp$
  338.                         rcvok:
  339.                         ChangeDirectory(current_dir$)
  340.                         set error off
  341.                     ENDIF
  342.                   ENDIF
  343.             ENDIF
  344.             IF command$ = "S" THEN
  345.                 RPRINT cr$+"Shutdown Initiated"
  346.                 continue = 0
  347.                 continue_commands = 0
  348.             ENDIF
  349.  
  350.         ' Change Directory
  351.         ENDIF
  352.         if len(command$) = 2 then
  353.              IF command$ = "CD" THEN
  354.                 IF access_level > 1 THEN
  355.                     RINPUT cr$+"Enter New Directory: ", new_dir$
  356.                     is_ok = ChangeDirectory(new_dir$)
  357.                     if is_ok = 0 then
  358.                         current_dir$ = new_dir$
  359.                     ELSE
  360.                         RPRINT cr2$+"Unable to change to directory!"
  361.                     ENDIF
  362.                 ENDIF
  363.             ENDIF
  364.  
  365.             IF command$ = "FS" Then
  366.                    RPRINT cr2$+"Current File Specification is "+file_spec$+cr$
  367.                    RINPUT cr$+"Enter New File Specification: ", file_spec$
  368.                    IF LEN(file_spec$) = 0 THEN
  369.                       file_spec$ = filespec
  370.                    ENDIF
  371.             ENDIF
  372.         ' Add a New User
  373.             IF command$ = "AU" THEN
  374.                 IF access_level > 2 THEN
  375.                     rprint cr4$
  376.                     RPRINT cr$+Header$+cr$
  377.                     RPRINT  "Add a new user." + cr$
  378.                     RINPUT cr$+"Enter new user's First name: ", new_first$
  379.                     RINPUT cr$+"Enter new user's Last name: ", new_last$
  380.                     RINPUT cr$+"Enter new user's Password: ", new_password$
  381.                     RINPUT cr$+"Enter new user's Access level: ", new_level$
  382.                     iLevel = val(new_level$)
  383.                     is_ok = AddUser(new_first$, new_last$, new_password$, iLevel)
  384.                     IF is_ok > 0 THEN
  385.                         RPRINT cr$+"Unable to add user record!" + cr$
  386.                     ELSE
  387.                         RPRINT cr$+new_first$+" "+new_last$+" added to datafile." + cr$
  388.                     ENDIF
  389.                 ENDIF
  390.             ENDIF
  391.  
  392.         ' Change an Existing User
  393.             IF command$ = "CU" THEN
  394.                 IF access_level > 2 THEN
  395.                     rprint cr4$
  396.                     RPRINT cr$+Header$+cr$
  397.                     RPRINT  "Change an existing user." + cr$
  398.                     RINPUT cr$+"Enter user's First name: ", new_first$
  399.                     RINPUT cr$+"Enter user's Last name: ", new_last$
  400.                     RINPUT cr$+"Enter user's new Password or blank to skip: ", new_password$
  401.                     RINPUT cr$+"Enter new Access Level: ", new_level$
  402.                     iLevel = val(new_level$)
  403.                     is_ok = ChangeUser(new_first$, new_last$, new_password$, iLevel)
  404.                     IF is_ok > 0 THEN
  405.                         RPRINT cr$+"Unable to change user record!" + cr$
  406.                     ELSE
  407.                         RPRINT cr$+new_first$+" "+new_last$+ " access level changed."+cr$
  408.                     ENDIF
  409.                 ENDIF
  410.             ENDIF
  411.  
  412.         ' Delete an Existing User
  413.             IF command$ = "DU" THEN
  414.  
  415.                 IF access_level > 2 THEN
  416.                     rprint cr4$
  417.                     RPRINT cr$+Header$+cr$
  418.                     RPRINT  "Delete an existing user." + cr$
  419.                     RINPUT cr$+"Enter user's First name: ", new_first$
  420.                     RINPUT cr$+"Enter user's Last name: ", new_last$
  421.                     is_ok = DeleteUser(new_first$, new_last$)
  422.                     IF is_ok > 0 THEN
  423.                         RPRINT cr$+"Unable to delete user record!" + cr$
  424.                     ELSE
  425.                         RPRINT cr$+new_first$+" "+new_last$+" deleted." + cr$
  426.                     ENDIF
  427.                 ENDIF
  428.             ENDIF
  429.         ENDIF
  430.     WEND
  431.     force_hangup:
  432.         HANGUP
  433. WEND
  434. Mprint "Script Terminated"
  435. END
  436.